class Solution(object):
    def canChoose(self, groups, nums):
        n = len(groups)
        t = len(nums)
        index = 0
        for i in range(n):
            m = len(groups[i])
            while index + m <= t and nums[index: index + m] != groups[i]:
                index += 1
            if index + m > t:
                return False
            else:
                index = index + m
        return True